import java.util.Scanner;

public class Test2 {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        // 注意 hasNext 和 hasNextLine 的区别
        while (in.hasNextInt()) { // 注意 while 处理多个 case
            int n = in.nextInt();
            int m = in.nextInt();
            if (n < m) {
                System.out.println(-1);
                return;
            }
            int[] a = new int[n];
            int[] hash = new int[n + 1];
            for (int i = 0; i < n; i++) {
                a[i] = in.nextInt();
                hash[a[i]]++;
            }
            int avgCount = (int)Math.ceil(1.0 * n / m);
            int maxCount = avgCount;
            int tmp = n;
            for (int i = 0; i <= tmp; i++) {
                if (m == 1) {
                    if (n == hash[i]) {
                        maxCount = Math.max(maxCount, hash[i]);
                        break;
                    } else if (hash[i] != 0 && n != hash[i]) {
                        System.out.println(-1);
                        return;
                    } else {
                        continue;
                    }
                }
                while (hash[i] > 0) {
                    if (hash[i] >= avgCount) {
                        m--;
                        n -= avgCount;
                        hash[i] -= avgCount;
                    } else {
                        m--;
                        n -= hash[i];
                        hash[i] = 0;
                    }
                }
            }
            System.out.println(maxCount);
        }
    }
}
